CC=g++
INCLUDE=-I.
CCFLAGS=#-arch i386
TEST_GRAPH=test_graph.tsk
TEST_SPCOUNTER= test_spcounter.tsk
TEST_TRIE=test_trie.tsk
PYEXT=boggle.so
TASK=boggle.tsk
PYEXTMK=make.py
OBJS=boggle.o
TEST_OBJS=test_graph.o
TEST_OBJSSP=test_SPCounter.o
TEST_OBJST=test_trie.o
LIBNAME=libboggle.a
LIBOBJS=$(OBJS)

all: $(TASK) $(LIBNAME) pyext

backend: $(TASK) $(LIBNAME)

$(TASK): $(OBJS)
	$(CC) $(CCFLAGS) -o $@ $^

pyext:
	python $(PYEXTMK) build
	python $(PYEXTMK) install

test: $(TEST_GRAPH) $(TEST_SPCOUNTER) $(TEST_TRIE)

$(LIBNAME): $(LIBOBJS)
	ar -r $@ $^

$(TEST_GRAPH): $(TEST_OBJS)
	$(CC) $(CCFLAGS) -o $@ $^
	
$(TEST_SPCOUNTER): $(TEST_OBJSSP)
	$(CC) $(CCFLAGS) -o $@ $^

$(TEST_TRIE): $(TEST_OBJST)
	$(CC) $(CCFLAGS) -o $@ $^

%.o:%.cpp
	$(CC) $(INCLUDE) $(CCFLAGS) -o $@ -c $<

clean:
	rm *o *tsk *a
	python $(PYEXTMK) clean --all
